﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

namespace TimeTableManagement.Controllers
{
    public class ManagementController : Controller
    {
        //
        // GET: /Management/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult CreateMultiUser(String filename)
        {
            string fileloc = Request.PhysicalApplicationPath + "Uploads\\" + filename;
            FileInfo info = new FileInfo(fileloc);
            bool fileExists = info.Exists;
            if (fileExists)
            {
                ViewBag.msg = "File <span class=\"style1\">\"" + filename + "\"</span> upload thành công";
            }
            else{
                ViewBag.msg = "File <span class=\"style1\">\"" + filename + "\"</span> upload thất bại";
            }
            return View();

        }
        [HttpPost]
        public string CreateMultiUser(String filename,String mode)
        {
            string fileloc = Request.PhysicalApplicationPath + "Uploads\\" + filename;
            string result = "";
            FileInfo info = new FileInfo(fileloc);
            bool fileExists = info.Exists;
            if (mode == "check")
            {
                if (fileExists)
                {
                    result = "ok";
                }
                else
                {
                    result = "non-exist";
                }
            }
            return result;
            

        }
    }
}
